﻿namespace AbpMediatrDemo
{
    using System.IO;

    using MediatR;

    public class PingHandler : IRequestHandler<PingCommand, PingCommandResult>
    {
        private readonly TextWriter _writer;

        public PingHandler(TextWriter writer)
        {
            this._writer = writer;
        }

        public PingCommandResult Handle(PingCommand message)
        {
            this._writer.WriteLine($"--- Handled Ping: {message.Message}");
            return new PingCommandResult { Message = message.Message + " Pong" };
        }
    }
}